%{
#include <stdio.h>

void yyerror(char *err);
int yylex();

%}

%token NEWLINE
%token TYPE_VOID TYPE_BOOL TYPE_CHAR TYPE_SHORT TYPE_INT TYPE_LONG TYPE_FLOAT TYPE_SIGNED TYPE_UNSIGNED
%token IDENTIFIER NUMBER

%union
{
	int iValue;
	float fValue;
	char *sValue;
};

%type <iValue> NUMBER;

%%

program:
	program program_element
	|	/*empty*/
	;


program_element:
	function_declaration
	|function_definition
	;

function_declaration:
	function_header ';'
	;

function_definition:
	function_header block
	;

function_header:
	func_type IDENTIFIER '(' function_param_list ')'
	;

function_param_list:
	function_param
	|function_param_list ',' function_param
	|	/* empty */
	;
	
function_param:
	var_type IDENTIFIER
	;

block:
	'{' '}'
	;

func_type:
	TYPE_VOID
	|var_type;

var_type:
	int_type
	|TYPE_BOOL
	|TYPE_FLOAT
	;

int_type:
	type_specifier
	|type_modifier type_specifier
	;

type_specifier:
	TYPE_CHAR
	|TYPE_SHORT
	|TYPE_INT
	|TYPE_LONG
	;

type_modifier:
	TYPE_SIGNED
	|TYPE_UNSIGNED
	;

%%
